/*
 * @Author: luthor luthor-li@qq.com
 * @Date: 2024-03-05 20:38:56
 * @LastEditors: fisher luthor-li@qq.com
 * @LastEditTime: 2024-09-25 15:35:07
 * @FilePath: \allfront\src\utils\fpstream\modules\Gls\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export default class {
  constructor(send2Ue, listen2Ue) {
    this.send2Ue = send2Ue;
    this.listen2Ue = listen2Ue;
    this.baseCmd = "/Gls";
  }
  // resetScene(data = {}, cb) {
  //   this.send2Ue(`${this.baseCmd}/ResetScene`, data, cb);
  // }
  resetScene(data = {}, cb) {
    this.send2Ue(`/reset/all`, data, cb);
  }
  loadLevel(data, cb) {
    this.listen2Ue(`${this.baseCmd}/LoadStreamingLevel_Callback`, cb);
    this.send2Ue(`${this.baseCmd}/LoadStreamingLevel`, {
      Levels: data,
    });
  }
  unloadLevel(data, cb) {
    this.send2Ue(
      `${this.baseCmd}/UnloadStreamingLevel`,
      {
        Levels: data,
      },
      cb
    );
  }
  setActorVisibleByTags(data = {}, cb) {
    // 发送播放漫游指令
    this.send2Ue(`${this.baseCmd}/ShowModelChildrenByTag`, data, cb);
  }
  /**
   * @description: 设置夜景，东莞定制需求
   * @param {boolean} data
   * @return {*}
   */
  setNightview(data, cb) {
    let type = "";
    if (data) {
      type = "Night";
    } else {
      type = "Day";
    }
    this.send2Ue(
      `/BP_DGBusiness/DayOrNightLight`,
      {
        Type: type,
      },
      cb
    );
  }
  /**
   * @description: 设置建筑特效状态，东莞定制需求
   * @param {string} name
   * @param {boolean} status
   * @return {*}
   */
  setBuildEffect(name, status, cb) {
    this.send2Ue(
      `/BP_DGBusiness/SetPostProcessStatus`,
      {
        Tag: name,
        Status: status,
      },
      cb
    );
  }

  /**
   * @description: 高亮模型
   * @param {*} data 模型tag名称
   * @param {*} type 高亮类型：1、蓝色；2、金色；3、红色；
   * @return {*}
   */
  highlightActor(data, type = 1) {
    this.send2Ue(`${this.baseCmd}/HighLightModelByTag`, {
      Tag: data,
      Channel: parseInt(type),
    });
  }
  /**
   * @description: 取消模型高亮
   * @param {*} data 模型tag名称
   * @return {*}
   */
  cancelHighlightActor(data) {
    this.send2Ue(`${this.baseCmd}/CancelHighLightModelByTag`, {
      Tag: data,
    });
  }

  /**
   * @description: 设置3dtiles服务
   * @param {*} data 数组或对象
   * @return {*}
   */
  setTilesetServer(data, cb) {
    let datalist = [];
    if (Array.isArray(data)) {
      datalist = data;
    } else {
      datalist.push(data);
    }

    this.send2Ue(
      "/BP_DGBusiness/Set3DTilesServe",
      {
        ServeList: datalist,
      },
      cb
    );
  }
}
